/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
    user-select: none;
}

/* Responsive container - adapts to iframe vs full browser */
.container {
    display: flex;
    width: 100%;
    height: 450px; /* Default iframe height */
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Full browser mode */
@media (min-height: 500px) {
    .container {
        height: 90vh;
    }
}

/* Tool shelf - left panel */
.tool-shelf {
    width: 180px;
    background: #2c3e50;
    color: white;
    padding: 15px 10px;
    overflow-y: auto;
    flex-shrink: 0;
}

.tool-category {
    margin-bottom: 20px;
}

.tool-category h4 {
    font-size: 12px;
    margin-bottom: 8px;
    color: #bdc3c7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.tool-btn {
    padding: 8px 4px;
    border: none;
    background: #34495e;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
    min-height: 32px;
}

.tool-btn:hover {
    background: #4a6741;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.tool-btn.active {
    background: #27ae60;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.3);
}

/* Pressure control */
.pressure-control {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #34495e;
}

.pressure-control label {
    display: block;
    font-size: 11px;
    margin-bottom: 5px;
    color: #bdc3c7;
}

#pressure-slider {
    width: 100%;
    margin-bottom: 5px;
}

#pressure-value {
    font-size: 10px;
    color: #27ae60;
}

/* Main drawing area */
.drawing-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ecf0f1;
    position: relative;
}

.canvas-container {
    flex: 1;
    position: relative;
    margin: 10px;
    background: white;
    border-radius: 4px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

#drawing-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: block;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.stroke-guide {
    position: absolute;
    border: 2px dashed #3498db;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stroke-guide.active {
    opacity: 0.5;
}

/* Stroke type selector */
.stroke-selector {
    display: flex;
    padding: 10px;
    gap: 5px;
    background: #34495e;
    flex-wrap: wrap;
}

.stroke-btn {
    flex: 1;
    min-width: 80px;
    padding: 8px 4px;
    border: none;
    background: #2c3e50;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.stroke-btn:hover {
    background: #3498db;
    transform: translateY(-1px);
}

.stroke-btn.active {
    background: #e74c3c;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.3);
}

/* Control panel - right side */
.control-panel {
    width: 160px;
    background: #ecf0f1;
    padding: 15px 10px;
    overflow-y: auto;
    flex-shrink: 0;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 20px;
}

.action-buttons button {
    padding: 10px 5px;
    border: none;
    background: #3498db;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
    min-height: 36px;
}

.action-buttons button:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Exercises section */
.exercises {
    margin-bottom: 20px;
}

.exercises h4 {
    font-size: 12px;
    margin-bottom: 10px;
    color: #2c3e50;
    text-transform: uppercase;
}

.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.exercise-btn {
    padding: 8px;
    border: none;
    background: #95a5a6;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.2s ease;
    text-align: left;
}

.exercise-btn:hover {
    background: #7f8c8d;
    transform: translateX(2px);
}

.exercise-btn.active {
    background: #f39c12;
}

/* Results panel */
.results-panel h4 {
    font-size: 12px;
    margin-bottom: 10px;
    color: #2c3e50;
    text-transform: uppercase;
}

.progress-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 5px;
    background: white;
    border-radius: 3px;
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    max-width: 200px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    line-height: 1.4;
}

.tooltip.show {
    opacity: 1;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 400px;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

#hint-content p {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.5;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: 450px;
    }
    
    .tool-shelf {
        width: 100%;
        height: 80px;
        display: flex;
        overflow-x: auto;
        padding: 5px;
    }
    
    .tool-category {
        margin-right: 15px;
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .control-panel {
        width: 100%;
        height: 60px;
        display: flex;
        gap: 10px;
        align-items: center;
        padding: 5px 10px;
    }
    
    .action-buttons {
        display: flex;
        gap: 5px;
        margin-bottom: 0;
    }
    
    .exercises, .results-panel {
        display: none;
    }
    
    .stroke-selector {
        order: -1;
    }
}

/* Touch-friendly sizing */
@media (pointer: coarse) {
    .tool-btn, .stroke-btn, .exercise-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .action-buttons button {
        min-height: 44px;
    }
}